home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / gnome-doc-tool < prev    next >
Encoding:
Text File  |  2007-04-09  |  7.7 KB  |  251 lines

  1. #!/bin/sh
  2. # gnome-doc-html - Convert documentation to HTML
  3. # gnome-doc-html.  Generated from gnome-doc-html.in by configure.
  4. # Copyright (C) 2006 Shaun McCance <shaunm@gnome.org>
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. # General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. #
  20. # As a special exception to the GNU General Public License, if you
  21. # distribute this file as part of a program that contains a
  22. # configuration script generated by Autoconf, you may include it under
  23. # the same distribution terms that you use for the rest of that program.
  24.  
  25. progname=`echo "$0" | sed 's%^.*/%%'`
  26.  
  27. PROGRAM=gnome-doc-html
  28. PACKAGE=gnome-doc-utils
  29. VERSION=0.10.3
  30. prefix=/usr
  31. datarootdir=@datarootdir@
  32. datadir=${prefix}/share
  33. pkgdatadir=${prefix}/share/gnome-doc-utils
  34. xsltdir=${prefix}/share/xml/gnome/xslt
  35.  
  36. function error {
  37.     echo "$progname: $1" 1>&2;
  38.     exit 1;
  39. }
  40.  
  41. function print_help {
  42.     cat <<EOF
  43. Usage: $progname <COMMAND> [OPTIONS] FILE
  44. Process a documentation file.
  45.  
  46. COMMAND is one of:
  47.   html       convert the document to HTML
  48.   help       display this help and exit
  49. EOF
  50. }
  51.  
  52. function print_help_html {
  53.     cat <<EOF
  54. Usage: $progname html [OPTIONS] FILE
  55. Convert FILE into HTML.
  56.  
  57. Basic Output Control:
  58.   -c, --css-file=FILE             file to output CSS to
  59.   -d, --chunk-depth=INT           how deep sections should be chunked
  60.   -e, --extension=EXT             the extension to append to output files
  61.   -n, --no-figures                do not copy figures into the output directory
  62.   -o, --output=PATH               the file or directory to output to
  63.  
  64. Formatting Control:
  65.   --admon-graphics-path=PATH      the path to the admonition graphics
  66.   --admon-graphics-size=INT       the size of the admonition graphics
  67.   --admon-graphics-extension=EXT  the extension of the admonition grahpics
  68.   --classsynopsis-language=LANG   the default programming language to be used
  69.                                   for classsynopsis elements
  70.   --funcsynopsis-style=STYLE      the style to be used to render funcsynopsis
  71.                                   elements, either 'KR' or 'ANSI'
  72.  
  73. Miscellaneous:
  74.   -v, --verbose                   print all the commands executed
  75.   -V, --version                   print version information and exit
  76.   -h, --help                      display this help and exit
  77. EOF
  78. }
  79. function echo_verbose {
  80.     if [ "x$doc_verbose" == "x1" ]; then echo $1; fi
  81. }
  82. function mkdir_p {
  83.     dir='';
  84.     echo $1 | sed -e 's/\//\n/g' | while read d; do
  85.     dir="$dir$d/"
  86.     if [ ! -d "$dir" ]; then
  87.         echo_verbose "mkdir \"$dir\""
  88.         mkdir "$dir"
  89.     fi
  90.     done;
  91. }
  92.  
  93. function DO_html {
  94.     longopts='
  95.       -lcss-file:
  96.       -lchunk-depth:
  97.       -lextension:
  98.       -lno-figures
  99.       -loutput:
  100.       -ladmon-graphics-path:
  101.       -ladmon-graphics-size:
  102.       -ladmon-graphics-extension:
  103.       -lclasssynopsis-language:
  104.       -lfuncsynopsis-style:
  105.       -lverbose
  106.       -lversion
  107.       -lhelp
  108.     ';
  109.     options=`getopt -qn$progname $longopts -- c:d:e:o:nvVh "$@"`
  110.     if [ "$?" != "0" ]; then print_help_html 1>&2; exit 1; fi
  111.     eval set -- "$options";
  112.     while [ "$1" != "--" ]; do
  113.     case "$1" in
  114.         -c | --css-file)
  115.         doc_css_file="$2";;
  116.         -d | --chunk-depth)
  117.         doc_chunk_depth="$2";;
  118.         -e | --extension)
  119.         doc_extension="$2";;
  120.         -n | --no-figures)
  121.         doc_no_figures="1";;
  122.         -o | --output)
  123.         doc_output="$2";;
  124.  
  125.         --admon-graphics-path)
  126.         doc_admon_graphics_path="$2";;
  127.         --admon-graphics-size)
  128.         doc_admon_graphics_size="$2";;
  129.         --admon-graphics-extension)
  130.         doc_admon_graphics_extension="$2";;
  131.         --classsynopsis-language)
  132.         doc_classsynopsis_language="$2";;
  133.         --funcsynopsis-style)
  134.         doc_funcsynopsis_style="$2";;
  135.  
  136.         -v | --verbose)
  137.         doc_verbose=1;;
  138.  
  139.         -V | --version)
  140.         echo "$PROGRAM ($PACKAGE) $VERSION"
  141.         exit 0;;
  142.         -h | --help)
  143.         print_help_html
  144.         exit 0;;
  145.         --)
  146.         print_help_html 1>&2
  147.         exit 1;;
  148.     esac
  149.     shift
  150.     done
  151.     shift
  152.  
  153.     if [ "$#" != "1" ]; then print_help_html 1>& 2; exit 1; fi;
  154.     doc_input="$1"
  155.     if [ ! -f "$doc_input" ]; then error "$doc_input: No such file"; fi
  156.     doc_indir=$( (cd $(dirname $doc_input) && pwd) )
  157.     doc_infile=$(basename $doc_input)
  158.     if [ "x${doc_infile: -4}" == "x.xml" ]; then
  159.     doc_inbase=${doc_infile:0:$((${#doc_infile}-4))}
  160.     else
  161.     doc_inbase="$doc_infile"
  162.     fi
  163.  
  164.     if [ "x$doc_output" == "x" ]; then
  165.     doc_outdir=`pwd`
  166.     if [ "x$doc_extension" == "x" ]; then doc_extension='.xhtml'; fi
  167.     doc_outfile="${doc_inbase}${doc_extension}"
  168.     elif [ -d "$doc_output" -o "${doc_output: -1}" == "/" ]; then
  169.     mkdir_p "$doc_output"
  170.     doc_outdir=`(cd "$doc_output" && pwd)`
  171.     if [ "x$doc_extension" == "x" ]; then doc_extension='.xhtml'; fi
  172.     doc_outfile="${doc_inbase}${doc_extension}"
  173.     else
  174.     dir=`dirname "$doc_output"`
  175.     mkdir_p "$dir"
  176.     doc_outdir=`(cd "$dir" && pwd)`
  177.     doc_outfile=`basename "$doc_output"`
  178.     if [ "x$doc_extension" == "x" ]; then
  179.         doc_extension=`echo "$doc_outfile" | grep -o '\..*'`
  180.     fi;
  181.     fi;
  182.     if [ "x${doc_outfile: -${#doc_extension}}" == "x${doc_extension}" ]; then
  183.     doc_outbase="${doc_outfile:0:$((${#doc_outfile}-${#doc_extension}))}"
  184.     else
  185.     doc_outbase="${doc_outfile}"
  186.     fi
  187.  
  188.     params='--param db.chunk.chunk_top 0'
  189.     params="$params --stringparam db.chunk.basename \"$doc_outbase\""
  190.     params="$params --stringparam db.chunk.extension \"$doc_extension\""
  191.     if [ "x$doc_chunk_depth" != "x" ]; then
  192.     params="$params --param db.chunk.max_depth $doc_chunk_depth"
  193.     fi
  194.     if [ "x$doc_css_file" != "x" ]; then
  195.     params="$params --stringparam db2html.css.file \"$doc_css_file\""
  196.     fi
  197.     if [ "x$doc_admon_graphics_path" != "x" ]; then
  198.     params="$params --stringparam db2html.admon.graphics_path"
  199.     params="$params \"$doc_admon_graphics_path\""
  200.     fi
  201.     if [ "x$doc_admon_graphics_size" != "x" ]; then
  202.     params="$params --stringparam db2html.admon.graphics_size"
  203.     params="$params \"$doc_admon_graphics_size\""
  204.     fi
  205.     if [ "x$doc_admon_graphics_extension" != "x" ]; then
  206.     params="$params --stringparam db2html.admon.graphics_extension"
  207.     params="$params \"$doc_admon_graphics_extension\""
  208.     fi
  209.     if [ "x$doc_classsynopsis_language" != "x" ]; then
  210.     params="$params --stringparam db2html.classsynopsis.language"
  211.     params="$params \"$doc_classsynopsis_language\""
  212.     fi
  213.     if [ "x$doc_funcsynopsis_style" != "x" ]; then
  214.     params="$params --stringparam db2html.funcsynopsis.style"
  215.     params="$params \"$doc_funcsynopsis_style\""
  216.     fi
  217.  
  218.     cmd="xmllint --noent --xinclude \"$doc_indir/$doc_infile\" |\
  219.       xsltproc $params -o \"$doc_outdir/$doc_outfile\" \"$xsltdir/docbook/html/db2html.xsl\" -"
  220.     echo_verbose "$cmd"
  221.     eval "$cmd"
  222.  
  223.     if [ "x$doc_no_figures" != "x1" -a "$doc_indir" != "$doc_outdir" ]; then
  224.     xmllint --noent --xinclude "$doc_indir/$doc_infile" \
  225.         | xsltproc "$xsltdir/docbook/utils/figures.xsl" - \
  226.         | while read fig; do
  227.         mkdir_p "$doc_outdir/"`dirname "$fig"`
  228.         cmd="cp \"$doc_indir/$fig\" \"$doc_outdir/$fig\""
  229.         echo_verbose "$cmd"
  230.         eval "$cmd"
  231.     done
  232.     fi
  233. }
  234.  
  235.  
  236. command="$1";
  237. shift;
  238. if [ "$command" = "html" ]; then
  239.     DO_html $@;
  240. elif [ "$command" = "-V" -o "$command" = "--version" ]; then
  241.     echo "$PROGRAM ($PACKAGE) $VERSION";
  242.     exit 0;
  243. elif [ "$command" = "help" ]; then
  244.     print_help;
  245.     exit 0;
  246. else
  247.     print_help 1>&2;
  248.     exit 1;
  249. fi;
  250.  
  251.